package com.dayu.finecomm.dsc;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;

/**
 * DSC 回调接口
 * 
 * @author hddz
 * @since 2017-07-31 16:36:00
 * @version V1.0
 * @param <C>
 */
public class DSCInterface {
	private ChannelInitializer<?> mChannel = null;

	DSCInterface(ChannelInitializer<?> channel) {
		mChannel = channel;
	}

	/**
	 * 发送用户数据给APP应用
	 * 
	 * @param socket
	 *            DTU remote address
	 * @param msg
	 */
	public void initChannel(ChannelHandlerContext ctx) {
		if (null != mChannel) {
			try {
				ctx.pipeline().addLast(mChannel);
				mChannel.channelRegistered(ctx);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 获取ChannelInitializer
	 * 
	 * @return
	 */
	public ChannelInitializer<?> getChannelHandler() {
		return mChannel;
	}
}
